package com.talkweb.cloudbaby.player.audio;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import tv.danmaku.ijk.media.sample.R;

/**
 * Created by wyf on 2016/7/28.
 */
public class AudioPlayerActivity extends FragmentActivity {
    private static final String TAG=AudioPlayerActivity.class.getSimpleName();

    public static final String EXTRA_URL="url";

    private AudioPlayer audioPlayer;
    private String url="";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.audio_player);
        initData();
        initView();
    }

    private void initData(){
        url=getIntent().getStringExtra(EXTRA_URL);
    }

    private void initView(){
        RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.app_video_box);
        relativeLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
        View view =new IjkAudioView(this);
        relativeLayout.addView(view, 0, params);

        audioPlayer=new AudioPlayer(this);
        audioPlayer.play(url);
    }
}
